<%@page import="Modelo.Querys"%>
<%@page import="Controlador.ConnectionDB"%>
<% 
String FinalMessage = "Incidencia Creada Exitosamente!";
String IncidenceCode = Querys.DecodeString(request.getParameter("IncidenceCode"));
String IncidenceName = Querys.DecodeString(request.getParameter("IncidenceName"));
String IncidenceDescription = Querys.DecodeString(request.getParameter("IncidenceDescription"));
String IncidenceIteration = request.getParameter("IncidenceIteration");
String IncidenceGlobal = request.getParameter("IncidenceGlobal");
if(IncidenceGlobal == null){
    IncidenceGlobal = "FALSE";
}

ConnectionDB c = new ConnectionDB();
if (c.Connect()) {
        int r = c.getUpdate("insert into Incident (Code, Name, Description, Iterations, Global) values ('" + IncidenceCode + "','" + IncidenceName + "','" + IncidenceDescription + "'," + IncidenceIteration + ",'" + IncidenceGlobal + "');");
        if (r > 0) {
            c.commit(true);
        } else {
            FinalMessage = "No se pudo ingresar los datos";
        }
        c.close();
    } else {
        FinalMessage = "No se pudo Conectar a la Base de Datos";
    }
%>
<jsp:forward page="create_incidence.jsp">
    <jsp:param name="FinalMessage" value="<%=FinalMessage%>" />        
</jsp:forward>